<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>整蛊宝典</title>
    <link rel="stylesheet" href="mim-common.css">
    <style>
        header {
            background: #409eff;
            color: #ffffff;
            padding: 30px;
            height: 100px;
            font-size: 20px;
        }

        nav {
            background: rgb(81, 45, 168) !important;
            color: #ffffff;
            padding: 0 30px 0 0;
            height: 50px;
            font-size: 16px;
        }

        nav div {
            float: left;
            height: 47px;
            line-height: 50px;
            display: inline-block;
            margin-left: 30px;
            cursor: pointer;
        }

        .footer {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
        }

        .onClick {
            border-bottom: 3px solid #ffffff;
        }

        .language-box {
            width: 50%;
            margin: 50px auto;
            height: 200px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
            padding: 20px;
        }

        .language-button, .language-client {
            text-align: center;
            margin: 50px auto;
        }

        #textarea {
            width: 100%;
            font-size: 16px;
            color: #343434;
            height: 150px;
            outline: none;
            border: none;
            resize: none;
        }

        #cont {
            width: 100%;
            font-size: 14px;
            color: #343434;
            height: 150px;
            outline: none;
            resize: none;
            border: 1px solid #dcdfe6;
            padding: 15px;
            transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
            vertical-align: middle;
            border-radius: 4px;
        }
        #cont_message_board {
            width: calc(100% - 30px);
            font-size: 14px;
            color: #343434;
            height: 70px;
            outline: none;
            resize: none;
            border: 1px solid #dcdfe6;
            padding: 15px 15px 50px 15px;
            vertical-align: middle;
            border-radius: 4px;
        }

        textarea::-webkit-input-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-moz-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-ms-input-placeholder {
            color: #b8c4ce !important;
        }

        .bomb_div {
            width: 50%;
            margin: 50px auto;
            height: 200px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
            padding: 20px;
        }
        #message_board_btn{
            top: 55px;
            position: absolute;
            right: 25px;
        }
        .message_board_div{
            width: 100%;
            height: 70vh;
            border: 10px dashed #52d3bb;
            border-radius: 5px;
            position: relative;
        }
        .message_board{
            padding: 15px;
            height: calc(70vh - 167px);
            overflow: auto;
        }
        .message_board::-webkit-scrollbar {
            width: 1px;
            height: 1px;
            background-color: transparent;
        }

        .message_board::-webkit-scrollbar-thumb {
            cursor: pointer;
            border-radius: 1px;
            background-color: transparent;
        }
        .message_board .group{
            padding: 16px 0;
            border-bottom: 1px solid #f2f2f2;
        }
        .message_board .group:first-child{
           margin-top: -15px;
        }
        .message_board .group .floor{
            font-size: 14px;
            line-height: 24px;
            font-weight: 400;
            color: #aaaaaa;
        }
        .message_board .group .floor span{
            font-size: 12px;
            line-height: 20px;
            font-weight: 400;
            color: #7981A2;
            float: right;
        }
        .message_board .group .message{
            font-size: 16px;
            line-height: 32px;
            font-weight: 400;
            color: #343434;
            margin-top: 10px;
        }
        .send_message{
            position: absolute;
            bottom: 10px;
            right: 10px;
        }
        .load{
            text-align: center;
            font-size: 14px;
            line-height: 24px;
            font-weight: 400;
            color: #343434;
            padding: 12px;
            cursor: pointer;
        }
    </style>
</head>
<body>
<header>
    <h1><span id="spanid">骂人宝典</span></h1>
    <mim-button type="danger" id="message_board_btn"><i class="iconfont"></i>留言板</mim-button>
</header>
<nav>
    <div class="onClick" type='1' buttonText="火力全开"
         ajaxUrl="http://www.taoerhuo.top/nmsl/public/index.php/index/api/full_fire">骂人宝典
    </div>
    <div type='2' buttonText="使劲夸" ajaxUrl="http://www.taoerhuo.top/nmsl/public/index.php/index/api/rainbow">彩虹屁</div>
    <div type='3' buttonText="接着舔" ajaxUrl="http://www.taoerhuo.top/nmsl/public/index.php/index/api/dog">舔狗日记</div>
    <div type='4' buttonText="再来一碗" ajaxUrl="http://www.taoerhuo.top/nmsl/public/index.php/index/api/soul">毒鸡汤</div>
</nav>
<mim-row class="valuable">
    <mim-col span="24">
        <div class="language-box" style="text-align: right">
            <textarea id="textarea" readonly></textarea>
            <mim-button type="warning" onClick="goGiveMoney()">打赏</mim-button>
            <mim-button type="primary" style="width:70px" onClick="copyText()">复制</mim-button>
        </div>
        <div class="language-button">
            <mim-button type="danger" onClick="vitalityFn()" class="buttonText">火力全开</mim-button>
            <mim-button type="default" onClick="clientShowFn()">我要投稿</mim-button>
        </div>
        <div class="language-client" style="display: none">
            <label>
                <strong>
                    <lable style="color: #f56c6c">*</lable>
                    您的名句:</strong>
                <textarea placeholder="请输入您的金口玉言,感谢您的支持^_^" style="width: 48%" id="cont"></textarea>
            </label>
            <br><br>
            <label style="margin-top: 20px">
                <strong>
                    <lable style="color: #f56c6c;visibility: hidden">*</lable>
                    联系方式:</strong>
                <mim-input type="text" placeholder="可以留下您的联系方式吗？(选填)" style="width: 50%" id="phone"></mim-input>
            </label>
            <br>
            <mim-button type="primary" size="medium" style="width: 10%;margin-top: 50px" id="submit">提交</mim-button>
        </div>
    </mim-col>
</mim-row>
<div class="footer">
    <span style="color: #409EFF;font-size: 18px">作者：叶念安；QQ：1298025852</span>
</div>
<mim-drawer drawerTitle="留言板" direction="btt" size="90%" class="mimDrawer">
    <mim-drawer-content>
        <mim-row>
            <mim-col span="12" style="margin-left: 25%">
                <div class="message_board_div">
                    <div class="message_board">
                        <div class="message_board_list">
                            <!--<div class="group">
                                <p class="floor"><span>1</span>楼</p>
                                <p class="message">你妈的花内裤挂在树上被猩猩瞻仰，被太阳晒的发黄，被情夫抚摸，被你炫耀！</p>
                            </div>
                            <div class="group">
                                <p class="floor"><span>1</span>楼</p>
                                <p class="message">也就你这烂了血逼的废物敢大言不惭的放这种弥天黑屁，再管不好你的鸡嘴老子亲自做一-个剧毒电源精水炸弹塞你逼里-炮把你轰进重症icu与你偏瘫窝囊废爹妈一起安度晚年。</p>
                            </div>-->
                        </div>
                        <div class="load" onclick="loadMore()">点击加载更多</div>
                    </div>

                    <textarea placeholder="请输入您的留言" id="cont_message_board" maxlength="100"></textarea>
                    <mim-button type="primary" class="send_message">留言发送</mim-button>
                </div>
            </mim-col>
        </mim-row>
    </mim-drawer-content>
</mim-drawer>

<script src="jquery-3.3.1.min.js"></script>
<script src="mim-common.js"></script>
<script>
    var url = "http://www.taoerhuo.top/nmsl/public/index.php/index/api/full_fire";
    var type = 1;
    var Page = 1,
        Size = '',
        hasMore = 1;
    init();
    sendMessageInit();
    function init() {
        MIM.ajaxUtils(url, {}, 'true', 'post', 'json', function (data) {
            if (data.code == 200) {
                $("#textarea").val(data.data.content);
            } else {
                MIM.prompt(data.message, 'danger', 2000);
            }
        }, function (ret) {
            MIM.prompt('失败', 'danger', 2000);
        });
    }
    function sendMessageInit(){
        if (hasMore == 1){
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/get_list', {
                page:Page
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    var retData = data.data.ly_list;
                    Size = data.data.per_page;
                    if (retData.length !== 0) {
                        hasMore = retData.length < Size ? 2 : 1;
                        if (hasMore == 2) {
                            $('.load').show().html('数据加载完毕')
                        }else {
                            $('.load').show().html('点击加载更多')
                        }
                        var html = appendHtml(retData);
                        $('.message_board_list').append(html);
                        Page++;
                    } else {
                        hasMore = 2;
                        $('.load').show().html('暂时没有数据~');
                    }
                } else {
                    MIM.prompt(data.message, 'danger', 2000);
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        }else {
            MIM.prompt('数据加载完毕', 'info', 2000);
        }

    }

    //切换
    $("nav div").on("click", function () {
        $(".language-client").hide();
        $("#spanid").html($(this).html());
        $(".buttonText").html($(this).attr("buttonText"));
        $(this).addClass("onClick").siblings().removeClass("onClick");
        url = $(this).attr("ajaxUrl");
        type = $(this).attr("type");
        init();
    });

    //    点击复制
    function copyText() {
        var target = document.getElementById("textarea");
        target.select(); // 选中文本
        document.execCommand("Copy"); // 执行浏览器复制命令
        MIM.prompt('复制成功', 'success', 2000);
    }

    //   去打赏
    function goGiveMoney() {
        window.location.href = 'http://pay.taoerhuo.top/'
    }

    // 我要投稿
    function clientShowFn() {
        $(".language-client").show();
    }

    //  火力全开
    function vitalityFn() {
        init()
    }

    //    提交信息
    $("#submit").on("click", function () {
        var cont = $("#cont").val();
        var phone = $("#phone").val();
        if (cont) {
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/tou', {
                content: cont,
                touch: phone,
                type: type
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    MIM.prompt(data.message, 'success', 2000);
                    $("#cont").val("");
                    $("#phone").val("")
                } else {
                    MIM.prompt('失败', 'danger', 2000);
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        } else {
            MIM.prompt('请输入你的金口玉言', 'danger', 2000);
        }
    });
    //留言板
    $("#message_board_btn").on("click",function () {

    }).drawerInit("mimDrawer");
    //手机进入的页面
    $(function () {
        function check() {
            var userAgentInfo = navigator.userAgent;
            var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
            var flag = true;
            for (var v = 0; v < Agents.length; v++) {
                if (userAgentInfo.indexOf(Agents[v]) > 0) {
                    flag = false;
                    break;
                }
            }
            return flag;
        }
        var wx = (function () {
                return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
            }
        )();
        if (wx) {
            window.location.href = "./h5-index.html"
        } else {
            if (check()) {

            } else {
                window.location.href = "./h5-index.html"
            }
        }
    });
//   页面渲染
    function appendHtml(ret) {
        var data = ret;
        var html = '';
        $.each(data, function (i, val) {
            html += '<div class="group">';
            html += '<p class="floor">'+val["liu_number"]+'<span>发布于：'+val["create_time"]+'</span></p>';
            html += '<p class="message">'+val["content"]+'</p>';
            html += '</div>';
        });
        return html;
    }
    //加载更多
    function loadMore() {
        sendMessageInit()
    }
    //发布留言
    $(".send_message").on("click",function () {
        var cont = $("#cont_message_board").val();
        if(cont){
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/to_liuyan', {
                content: cont,
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    $(".message_board_list").empty();
                   Page = 1;hasMore = 1;
                    sendMessageInit();
                    $("#cont_message_board").val("");
                    MIM.prompt('发表成功', 'success', 2000);
                } else {
                    MIM.prompt('失败', 'danger', 2000);
                    $("#cont_message_board").val("");
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        }else {
            MIM.prompt('请输入你的留言', 'danger', 2000);
        }
    })
</script>
</body>
</html>
